package com.csc531.adapters;

import java.util.ArrayList;

import com.csc531.DataTypes.Course;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

/**
 * @author Javier Figueroa
 * Abstract class that extends the BaseExpandableListAdapter from Android API
 */
public abstract class MyExpandableListAdapter extends BaseExpandableListAdapter {
	

	protected ArrayList<Course> _courses;
	
	private Context _callerClassContext;
	
	/**
	 * @param context
	 */
	public MyExpandableListAdapter(Context context) {
		_callerClassContext = context;
		_courses = new ArrayList<Course>();
	}

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getChild(int, int)
     */
    public abstract Object getChild(int groupPosition, int childPosition);
    
    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getChildId(int, int)
     */
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getChildrenCount(int)
     */
    public abstract int getChildrenCount(int groupPosition);

    /**
     * @return View of List Object
     */
    public TextView getGenericView() {
        // Layout parameters for the ExpandableListView
        AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, 64);

        TextView textView = new TextView(_callerClassContext);
        textView.setLayoutParams(lp);
        // Center the text vertically
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
        // Set the text starting position
        textView.setPadding(36, 0, 0, 0);
        return textView;
    }

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getChildView(int, int, boolean, android.view.View, android.view.ViewGroup)
     */
    public abstract View getChildView(int groupPosition, int childPosition, boolean isLastChild,
            View convertView, ViewGroup parent);

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getGroup(int)
     */
    public abstract Object getGroup(int groupPosition);
    
    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getGroupCount()
     */
    public abstract int getGroupCount();

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getGroupId(int)
     */
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#getGroupView(int, boolean, android.view.View, android.view.ViewGroup)
     */
    public abstract View getGroupView(int groupPosition, boolean isExpanded, View convertView,
            ViewGroup parent);

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#isChildSelectable(int, int)
     */
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    /* (non-Javadoc)
     * @see android.widget.ExpandableListAdapter#hasStableIds()
     */
    public boolean hasStableIds() {
        return true;
    }
    
    

}